//index.js
//获取应用实例
var usedata = require("../cashCouponDetaildata/cashCouponDetaildata.js");
const app = getApp()

Page({
  data: {
    cashCouponArr:'',
    navData: [
      {
        text: '可领取'
      },  
      {
        text: '已领取'
      },
      {
        text: '已使用'
      },
      {
        text: '已过期'
      },
    ],
    currentTab: 0,
    navScrollLeft: 0
  },
  //事件处理函数
  onLoad: function () {
    this.setData({
      cashCouponArr: usedata.cashCouponArr
    })
  },
  switchNav(event) {
    var cur = event.currentTarget.dataset.current;
    //每个tab选项宽度占1/3
    var singleNavWidth = this.data.windowWidth / (this.data.navData.lenght);
    //tab选项居中                            
    this.setData({
      navScrollLeft: (cur - 2) * singleNavWidth
    })
    if (this.data.currentTab == cur) {
      return false;
    } else {
      this.setData({
        currentTab: cur
      })
    }
  },
  switchTab(event) {
    var cur = event.detail.current;
    var singleNavWidth = this.data.windowWidth / (this.data.navData.lenght);
    this.setData({
      currentTab: cur,
      navScrollLeft: (cur - 2) * singleNavWidth
    });
  },
  goIndex: function () {//跳转到首页
    wx.switchTab({
      url: '../index/index'
    });
    console.log('popo')
  },
  goReadyLed: function () {//领取成功
    wx.showToast({
      title: '领取成功',
      icon: 'success',
      duration: 500
    })
  },
})